Package money
Class SimpleMoney
java.lang.Object
money.Money
money.SimpleMoney
A simple amount of Money with its currency.
- Author:
- Kent Beck, Robert Duvall (small updates and commenting)
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleMoney(int amount, String currency) Constructs simple money from the given amount and currency. -
Method Summary
Modifier and TypeMethodDescriptionAdds given money to this money.intamount()Returns only the amount of this money.currency()Returns only the currency of this money.booleaninthashCode()booleanisZero()Tests whether this money is zeromultiply(int factor) Multiplies this money by the given factor.negate()Negates this money.Subtracts given money from this money.toString()
-
Constructor Details
-
SimpleMoney
Constructs simple money from the given amount and currency.
-
-
Method Details
-
add
Description copied from class:MoneyAdds given money to this money. -
subtract
Description copied from class:MoneySubtracts given money from this money. -
multiply
Description copied from class:MoneyMultiplies this money by the given factor. -
negate
Description copied from class:MoneyNegates this money. -
isZero
public boolean isZero()Description copied from class:MoneyTests whether this money is zero -
amount
public int amount()Returns only the amount of this money. -
currency
Returns only the currency of this money. -
equals
-
hashCode
public int hashCode() -
toString
-